home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
bcrt.zip
/
BIOSCRT.PAS
next >
Wrap
Pascal/Delphi Source File
|
1988-08-29
|
22KB
|
556 lines
{ -********************************************************************** -}
{ BIOSCRT - A unit to allow text output through the standard BIOS calls }
{ This unit will work in both text and graphics modes. It was primarily }
{ written to allow use of the MS-DOS system font in graphics mode to }
{ compensate for the current lack of a BGI system font. Note: This method }
{ will *NOT* work with most Hercules boards because they don't properly }
{ support the BIOS calls in graphics mode. }
{ }
{ Notes: If you are using this unit on a CGA in the graphics mode, you }
{ should run the GRAFTABL program from your DOS supplimental program disk }
{ (this loads the extended CGA charater set into memory). }
{ }
{ To make this into a fully operational CRT type unit you will need to }
{ obtain a copy of Carley Phillips' "CRTI" unit which can be found on }
{ CompuServe in the Borland BPROGA Turbo library (DL2). Carley's CRTI }
{ unit will provide you with the sound, delay, and keyboard procedures. }
{ }
{ Written by Michael Day 23 August 1988 CIS:[73577,2225] }
{ Updated to Version 2.0 and renamed to BiosCrt 29 August 1988 }
{ This unit is released to the public domain by the author }
{ Mike Day UUCP:...!tektronix!reed!qiclab!bakwatr!mikeday }
{ Chief Bit Washer, Day Research, P.O. Box 22902, Milwaukie, OR 97222 }
{ Plans?...We don't need no stinkin' plans! }
{ -********************************************************************** -}
Unit BiosCrt;
interface
uses Dos;
var BiosWriteMode : byte; {Bios write mode to use for TFDD}
BiosTextAttr : byte; {Bios text attribute byte}
BiosStartAttr : byte; {Original startup attr}
LastBiosMode : byte; {last Bios screen mode in use}
LastBiosWidth : byte; {last Bios screen width used}
LastBiosPage : byte; {last Bios screen page used}
{--------------------------------------------------------------------------}
{-- Below are listed the important Bios variables for the video display. --}
{-- These are set by the Bios and are provided for reading only. Do not --}
{-- change any of these values or irratic display operation will result. --}
BiosMode : byte absolute $0040:$0049; {Current bios video mode}
BiosMaxX : word absolute $0040:$004A; {Text cols on display}
BiosCrtLength : word absolute $0040:$004C; {Crt buffer size in bytes}
BiosCursorPos : array [0..7] of word absolute $0040:0050; {Cursor pos}
BiosCursorMode: word absolute $0040:$0060; {Current cursor mode}
BiosActivePage: byte absolute $0040:$0062; {Current active video page}
BiosAddr6845 : word absolute $0040:$0063; {I/O address of controller}
Bios6845Mode : byte absolute $0040:$0065; {Current 6845 mode value}
BiosPalette : byte absolute $0040:$0066; {Current palette selected}
BiosMaxY : byte absolute $0040:$0084; {Text rows on display -1}
BiosCharSize : word absolute $0040:$0085; {Height of character cell}
BiosInfo : byte absolute $0040:$0087; {Misc video control info}
BiosInfo3 : byte absolute $0040:$0087; {Display card switch info}
BiosFlags : byte absolute $0040:$0087; {Misc video control flags}
BiosDCC : byte absolute $0040:$008A; {Display Combination Code}
BiosSavePtr : pointer absolute $0040:$00A8; {Pointer to Bios save area}
BiosFontTable : byte absolute $F000:$FA6E; {CGA (8x8) Bios font table}
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{-- The following are the inline macros used to access the BIOS routines --}
function BiosWhereX:integer; {get current cursor X pos}
inline(
$B7/$00 { mov BH,0}
/$B4/$03 { mov AH,3}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D { pop BP}
/$30/$E4 { xor AH,AH}
/$88/$D0); { mov AL,DL}
function BiosWhereY:integer; {get current cursor Y pos}
inline(
$B7/$00 { mov BH,0}
/$B4/$03 { mov AH,3}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D { pop BP}
/$30/$E4 { xor AH,AH}
/$88/$F0); { mov AL,DH}
procedure BiosWhereXY(var X,Y:integer); {get current cursor X,Y pos}
inline(
$B7/$00 { mov BH,0}
/$B4/$03 { mov AH,3}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D { pop BP}
/$07 { pop ES}
/$5B { pop BX}
/$26/$88/$37 { mov ES:[BX],DH}
/$07 { pop ES}
/$5B { pop BX}
/$26/$88/$17); { mov ES:[BX],DL}
procedure BiosGotoXY(X,Y:integer); {move cursor to indicated X,Y}
inline(
$58 { pop AX}
/$5A { pop DX}
/$88/$C6 { mov DH,AL}
/$B7/$00 { mov BH,0}
/$B4/$02 { mov AH,2}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D); { pop BP}
procedure BiosTextColor(FColor:integer); {Set text foreground color}
inline(
$58 { pop AX}
/$24/$0f { and AL,$0F}
/$8A/$26/>BiosTextAttr { mov AH,[>BiosTextAttr]}
/$80/$E4/$F0 { and AH,$F0}
/$08/$E0 { or AL,AH}
/$A2/>BiosTextAttr); { mov [>BiosTextAttr],AL}
procedure BiosTextBackGround(BColor:integer); {Set text background color}
inline(
$58 { pop AX}
/$B1/$04 { mov CL,4}
/$D2/$E0 { shl AL,CL}
/$8A/$26/>BiosTextAttr { mov AH,[>BiosTextAttr]}
/$80/$E4/$0F { and AH,$0F}
/$08/$E0 { or AL,AH}
/$A2/>BiosTextAttr); { mov [>BiosTextAttr],AL}
function GetBiosTextAttr:integer; {Get the current Bios text Attribute}
Inline(
$B7/$00 { mov BH,0}
/$B4/$08 { mov AH,8}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D { pop BP}
/$88/$E0 { mov AL,AH}
/$30/$E4); { xor AH,AH}
procedure SetBiosWriteMode(Mode:integer); {Set Bios write mode to use}
inline( {0=Reg, 1=Xor, 2=Bk}
$58 { pop AX}
/$A2/>BiosWriteMode); { mov [>BiosWriteMode],AL}
procedure SetBiosPage(Page:integer); {set active bios video page}
inline(
$58 { pop AX}
/$B4/$05 { mov AH,5}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D); { pop BP}
procedure BiosCursorOFF; {turn the cursor off}
inline(
$B4/$03 { mov AH,3}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D { pop BP}
/$80/$CD/$20 { or ch,$20}
/$B4/$01 { mov AH,1}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D); { pop BP}
procedure BiosCursorON; {turn the cursor on}
inline(
$B4/$03 { mov AH,3}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D { pop BP}
/$80/$E5/$1F { and CH,$1F}
/$B4/$01 { mov AH,1}
/$55 { push BP}
/$CD/$10 { int $10}
/$5D); { pop BP}
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{-- The following are the string procedures to access the BIOS routines ---}
procedure BiosWrite(S:String); {Bios based text write}
procedure BiosWriteLn(S:String); {Bios based text writeln}
procedure BiosClrEol; {clear to end of line}
procedure BiosClrScr; {clear the screen}
procedure BiosLowVideo; {turns off high intensity attr bit}
procedure BiosHighVideo; {turns on high intensity attr bit}
procedure BiosNormalVideo; {restores video attr to start up value}
procedure A